import requests
from bs4 import BeautifulSoup
import json
import time

# https://www.lddgo.net/string/text-shuffling-order 在线乱序工具

if __name__ == '__main__':
    cookie_string = "JSESSIONID=abcsvnyQdFcv95QtQcVTy; OUTFOX_SEARCH_USER_ID=1636139138@111.206.113.38; OUTFOX_SEARCH_USER_ID_NCOO=817363064.7977576; DICT_SESS=v2|ffBIzd5payYERMzlOfzY0pzhHkWnHe40gunfeF0MqLRU5OLlERLgLRpFnflfRf6K0OAhHkl0f6BRlMPMgLk4zl0lEPMlMhL64R; DICT_LOGIN=1||1698388867151; DICT_UT=wxoXQUDj6nA08zA28cQFgzep9hN2PE; __yadk_uid=MppOQHVJiVL8SmnzqvMiMqFGdSGOdM4n; rollNum=true; advertiseCookie=advertiseValue; ___rl__test__cookies=1698391588260"
    cookies = cookie_string.split("; ")
    cookie_dict = {cookie.split("=")[0]: cookie.split("=")[1] for cookie in cookies}
    jar = requests.cookies.RequestsCookieJar()
    for key, value in cookie_dict.items():
        jar.set(key, value)
    url = 'https://dict.youdao.com/wordbook/ajax?action=addword&le=eng&tags=tf-phrase'

    # 打开文件并读取其内容
    with open('text/phrase.txt', 'r') as file:
        for word in file:
            replace = word.replace("\n", "")
            new_url = url + ("&q=" + replace)
            res = requests.get(new_url, timeout=30, cookies=jar)
            if "adddone" not in str(res.text):
                print(replace + ":" + res.text)
